Skip to content

[Refactor] CoreDataManager 의존성 주입 전환 및 런치/탭바 구조 개선#39

Merged
jihyeonjjang merged 17 commits intodevfrom
feature/dicontainer
Jun 13, 2025
Merged

[Refactor] CoreDataManager 의존성 주입 전환 및 런치/탭바 구조 개선#39
jihyeonjjang merged 17 commits intodevfrom
feature/dicontainer

Conversation

@jihyeonjjang
Copy link
Copy Markdown
Collaborator

@jihyeonjjang jihyeonjjang commented Jun 12, 2025

변경 내용

  • CoreDataManager 싱글톤 패턴 제거 및 의존성 주입(DI) 방식으로 전환
  • 각 ViewModel에 CoreDataManager 및 VideoService를 명시적으로 주입
  • MainViewController → TabBarViewController로 rename
  • ❗아직 생성되지 않은 ViewModel은 주석 처리 상태로 보류 중

목적

  • 싱글톤 패턴의 단점
    • 객체 생명주기 제어 불가
      • 싱글톤 패턴은 앱 종료 전까지 메모리에서 해제되지 않음. 필요없는 시점에도 메모리를 사용하게 되어 메모리 누수로 이어질 수 있음.
    • 동시 접근 제어필요, Thread-safe 구현 복잡
  • 의존성 주입으로 변경
    • DIContainer를 통한 의존성 주입
    • CoreDataManager 인스턴스를 공유
    • 더 이상 참조하지 않으면 ARC가 해제 (순환 참조 주의)

- DIContainer를 통해 CoreDataManager와 PixabayVideoService 인스턴스를 주입
- LaunchScreenViewController와 TabBarViewController에 ViewModel 생성 및 주입 처리
- Info.plist에서 Main 스토리보드 제거
- SceneDelegate에서 DIContainer를 통해 LaunchScreenViewController 코드로 초기화
- LaunchScreenViewController UI를 코드로 재구성
- Main.storyboard에서 Launch 관련 뷰 제거
- LaunchScreen.storyboard에서 UI 요소 위치 및 크기 조정
… 기반 구조로 변경

- TabBarViewController가 CoreDataManager 대신 TabBarViewModel을 주입받도록 수정
- setupTabBar() 로직을 제거하고 viewModel에서 탭 구성 로직 위임
- 네트워크 및 CoreData 초기화 로직을 loadInitialData()로 이동
- performSegue 기반 화면 전환을 transitionToMain()로 대체
- LaunchScreenViewModel 생성 및 DI를 통한 초기화 구조 반영
- ViewModel에서 TabBarViewController 생성 책임 분리
- NSFetchedResultsController에 전달되는 fetchRequest에 sortDescriptors 설정
@korbit-ai
Copy link
Copy Markdown

korbit-ai Bot commented Jun 12, 2025

You've used up your 5 PR reviews for this month under the Korbit Starter Plan. You'll get 5 more reviews on June 22nd, 2025 or you can upgrade to Pro for unlimited PR reviews and enhanced features in your Korbit Console.

@jihyeonjjang jihyeonjjang changed the title [refactor] CoreDataManager 의존성 주입 전환 및 런치/탭바 구조 개선 [Refactor] CoreDataManager 의존성 주입 전환 및 런치/탭바 구조 개선 Jun 12, 2025
@jihyeonjjang jihyeonjjang removed the request for review from vinyl-nyl June 12, 2025 16:20
- Home, Like, MyPage 스토리보드 객체와 VC 인스턴스 생성 로직 분리
- ViewModel 주입 부분은 추후 작업을 위해 주석 처리 상태로 유지
Copy link
Copy Markdown
Collaborator

@kdn0325 kdn0325 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

@giseungNoh giseungNoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다.

Copy link
Copy Markdown
Owner

@TeddKo TeddKo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

Comment thread PickaView/App/DIContainer.swift Outdated
@jihyeonjjang jihyeonjjang merged commit 4c50006 into dev Jun 13, 2025
@jihyeonjjang jihyeonjjang deleted the feature/dicontainer branch June 13, 2025 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants